import {
	request,
	baseUrl
} from "../../request.js"

//域名 端口号
//var baseUrl = 'https://wzxlovemzy.com:6001/user'


/**
 * 1，支付
 */
export function getPayOrderInfo(price) {
	return request({
		url: baseUrl + '/zfb/getPayment',
		method: 'POST',
		data: {
			price
		}
	})
}

/**
 * 2，查询余额
 */
export function queryBalance() {
	return request({
		url: baseUrl + '/wallet/queryBalance?userId=' + uni.getStorageSync('userId'),
		method: 'GET'
	})
}

/**
 * 3，充值，添加历史记录
 * @param {Object} price
 * @param {Object} type
 */
export function addBalance(price, type, method, orderId, accountsObject) {
	return request({
		url: baseUrl + '/wallet/addBalance',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			price,
			type,
			state: 0,
			method,
			orderId: orderId || '',
			accountsObject: accountsObject || ''
		}
	})
}

/**
 * 4，查询充值记录
 */
export function queryNotes(method) {
	return request({
		url: baseUrl + '/notes/findById/userId=' + uni.getStorageSync('userId') + '&method' + method || '',
		method: 'GET'
	})
}

/**
 * 5，添加历史记录
 */
export function insert(price, type, method, orderId, accountsObject) {
	return request({
		url: baseUrl + '/notes/insert',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			price,
			type,
			state: 0,
			method,
			orderId: orderId || '',
			accountsObject: accountsObject || ''
		}
	})
}

/**
 * 6，账单查询
 * @param {Object} year
 * @param {Object} mouth
 */
export function queryPayAndIncome(year, mouth, pageNum, pageSize) {
	return request({
		url: baseUrl + '/notes/queryPayAndIncome',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			yser: year || '',
			mouth: mouth || '',
			pageNum: pageNum || 1,
			pageSize: pageSize || 20
		}
	})
}

export function queryPayAndIncomeByPage(year, mouth, pageNum, pageSize) {
	return request({
		url: baseUrl + '/notes/queryPayAndIncomeByPage',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			yser: year || '',
			mouth: mouth || '',
			pageNum: pageNum || 1,
			pageSize: pageSize || 20
		}
	})
}

/**
 * 7，提现
 */
export function cashWithdrawal(price, newPwd) {
	return request({
		url: baseUrl + '/wallet/cashWithdrawal',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			price,
			newPwd
		}
	})
}


//8，修改支付密码
export function httpUpdatePwd(newPwd, oldPwd) {
	return request({
		url: baseUrl + '/wallet/updatePwd',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			newPwd,
			oldPwd
		}
	})
}

//9，忘记支付密码
export function httpForgetPwd(code, newPwd, phone) {
	return request({
		url: baseUrl + '/wallet/forgetPwd',
		method: 'POST',
		data: {
			userId: uni.getStorageSync('userId'),
			newPwd,
			code,
			phone
		}
	})
}